package com.kexuexiong.demo.bear.controller.caffeine;

import com.kexuexiong.demo.bear.common.dto.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

@Api(tags = {"caffeine缓存"})
@RestController
@RequestMapping("/caffeine")
@Slf4j
public class CaffeineController {

    @Autowired
    private CacheManager cacheManager;

    @RequestMapping(value = "list",method = {RequestMethod.GET})
    @ApiOperation(value = "listCache",notes = "获取所有的缓存")
    public Result listCache() {
        Collection<String> cacheNames = cacheManager.getCacheNames();
        return Result.success(cacheNames);
    }
}
